<%@ page import="auctionatr.Auction"%>
<html itemscope itemtype="http://schema.org/Product">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="layout" content="main" />
<g:set var="entityName"
	value="${message(code: 'auction.label', default: 'Auction')}" />
<title><g:message code="auction.anzeigen.label"
		args="[entityName]" /></title>
<!--  original: code="default.show.label" -->

<!-- Add the following three tags inside head -> G+ -->
<meta itemprop="name"
	content="${fieldValue(bean: auctionInstance, field: "name")}">
<meta itemprop="description"
	content="${fieldValue(bean: auctionInstance, field: "description")}">
<meta itemprop="image"
	content="${createLink(controller:'auction', action:'auctionImage', id:fieldValue(bean: auctionInstance, field: "id"))}">

<!-- Place this render call where appropriate -> G+ -->
<script type="text/javascript">
  window.___gcfg = {lang: 'de'};

  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
</script>
<!-- -->

<!-- META Tags für Facebook OpenGraph -->
<meta property="og:title"
	content="${fieldValue(bean: auctionInstance, field: "name")}" />
<meta property="og:type" content="product" />
<meta property="og:image"
	content="${createLink(controller:'auction', action:'auctionImage', id:fieldValue(bean: auctionInstance, field: "id"))}" />
<meta property="og:url"
	content="${createLink(controller:'auction', action:'show', id:fieldValue(bean: auctionInstance, field: "id"))}" />
<meta property="og:site_name" content="auctionatr" />
<meta property="fb:admins" content="1144472384" />
<!-- -->
</head>
<body>
	<!-- Facebook JS laden -> für Like Button -->
	<div id="fb-root"></div>
	<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=8729518278";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
	<!-- -->
	<div class="body">
		<h1>
			<g:message code="auction.anzeigen.label" args="[entityName]" />
			:
			${fieldValue(bean: auctionInstance, field: "name")}
			<g:if
				test="${session?.admin || session?.userid == auctionInstance.users.id}">[<g:link
					controller="auction" action="report"
					id="${fieldValue(bean: auctionInstance, field: 'id')}">
					<g:message code="auction.auktionsliste.reportLink.label"
						default="Show Report" />
				</g:link>]</g:if>
			<!--  original: code="default.show.label" -->
		</h1>
		<g:if test="${flash.message}">
			<div class="message">
				${flash.message}
			</div>
		</g:if>
		<div class="dialog">
			<table>
				<tbody>
					<g:if test="${auctionInstance?.picture}">
						<tr>
							<td rowspan="14" align="left"><img class="auctionImage"
								width="150"
								src="${createLink(controller:'auction', action:'auctionImage', id:fieldValue(bean: auctionInstance, field: "id"))}" />
							</td>
							<td><g:link action="show" id="${auctionInstance.id}">
									<img
										title="${message(code: 'auction.share.qr.cal', default: 'Calendar event for this auction')}"
										alt="QR Code mit Kalenderereignis für diese Auktion"
										width="175" height="175"
										src="https://chart.googleapis.com/chart?chs=175x175&cht=qr&chl=BEGIN:VEVENT SUMMARY:${fieldValue(bean: auctionInstance, field: "name")} DTSTART:${fieldValue(bean: auctionInstance, field: "dateCreated")} DTEND:${fieldValue(bean: auctionInstance, field: "finishDate")} SUMMARY:${fieldValue(bean: auctionInstance, field: "description")} DESCRIPTION:${createLink(controller:'auction', absolute:'true', action:'show', id:fieldValue(bean: auctionInstance, field: "id"))} END:VEVENT">
									</img>
								</g:link></td>
						</tr>
					</g:if>
					<g:else>
						<tr>
							<td rowspan="14"><g:link action="show"
									id="${auctionInstance.id}">
									<img class="auctionImage" width="200"
										src="%3D%3D">
									</img>
								</g:link></td>
							<td><g:link action="show" id="${auctionInstance.id}">
									<img
										title="${message(code: 'auction.share.qr.cal', default: 'Calendar event for this auction')}"
										alt="QR Code mit Kalenderereignis für diese Auktion"
										width="175" height="175"
										src="https://chart.googleapis.com/chart?chs=175x175&cht=qr&chl=BEGIN:VEVENT SUMMARY:${fieldValue(bean: auctionInstance, field: "name")} DTSTART:${fieldValue(bean: auctionInstance, field: "dateCreated")} DTEND:${fieldValue(bean: auctionInstance, field: "finishDate")} SUMMARY:${fieldValue(bean: auctionInstance, field: "description")} DESCRIPTION:${createLink(controller:'auction', absolute:'true', action:'show', id:fieldValue(bean: auctionInstance, field: "id"))} END:VEVENT">
									</img>
								</g:link></td>
						</tr>
					</g:else>
				</tbody>
			</table>

			<table>
				<tbody>
					
					<tr class="prop">
						<td valign="top" class="name"><g:message
								code="auction.description.label" default="Description" /></td>

						<td valign="top" class="value">
							${fieldValue(bean: auctionInstance, field: "description")}
						</td>

					</tr>
					<tr class="prop">
						<td valign="top" class="name"><g:message
								code="auction.finishDate.label" default="Finish Date" /></td>

						<td valign="top" class="value"><g:formatDate
								format="${message(code: 'default.date.format', default: 'DateFormat')}"
								date="${auctionInstance?.finishDate}" /></td>

					</tr>


					<tr class="prop">
						<td valign="top" class="name"><g:message
								code="auction.startPrice.label" default="Start Price" /></td>

						<td valign="top" class="value"><g:formatNumber
								number="${auctionInstance.startPrice}" type="currency"
								currencyCode="EUR" /></td>

					</tr>

					<tr class="prop">
						<td valign="top" class="name"><g:message
								code="auction.highestBid.label" default="Bids" /></td>


						<td valign="top" class="value"><b> <g:formatNumber
									number="${lastBid.gebot}" type="currency" currencyCode="EUR" />
						</b> <g:if
								test="${ session?.username != null && session?.userid != auctionInstance.users.id && auctionInstance.isOver() != true}">[<g:link
									controller="bid" action="create"
									id="${fieldValue(bean: auctionInstance, field: 'id')}">
									<g:message code="auction.newBid.label" default="New Bid" />
								</g:link>]</g:if>
					</tr>
					<!--  leere Zeile zur besseren Übersichtlichkeit -->
					<tr>
						<td></td>
						<td></td>
					</tr>

					<tr class="prop">
						<td valign="top" class="name"><u><g:message
									code="auction.details.label" default="Details" /></u></td>
						<td></td>
					</tr>

					<tr class="prop">
						<td valign="top" class="name"><g:message
								code="auction.seller.label" default="Seller" /></td>

						<td valign="top" class="value">
							<g:link controller="user" action="show" id="${auctionInstance.users.id }">${auctionInstance.users.username}</g:link>
						</td>
					

					<tr class="prop">
						<td valign="top" class="name"><g:message
								code="auction.state.label" default="State" /></td>

						<td valign="top" class="value">
							${fieldValue(bean: auctionInstance, field: "state")}
						</td>

					</tr>

					<tr class="prop">
						<td valign="top" class="name"><g:message
								code="auction.shipment.label" default="Shipment" /></td>

						<td valign="top" class="value">
							${fieldValue(bean: auctionInstance, field: "shipment")}
						</td>

					</tr>

					<tr class="prop">
						<td valign="top" class="name"><g:message
								code="auction.category.label" default="Category" /></td>

						<td valign="top" class="value"><g:link controller="auction"
								action="showCategory" id="${auctionInstance.categories.id}">
								${fieldValue(bean: auctionInstance.categories, field: "name")}
							</g:link></td>

					</tr>


					<tr class="prop">
						<td valign="top" class="name"><g:message
								code="auction.dateCreated.label" default="Start Date" /></td>

						<td valign="top" class="value"><g:formatDate
								format="${message(code: 'default.date.format', default: 'DateFormat')}"
								date="${auctionInstance?.dateCreated}" /></td>

					</tr>

					<tr class="prop">
						<td valign="top" class="name"><g:message
								code="auction.deliveryCosts.label" default="Delivery Costs" />
						</td>

						<td valign="top" class="value"><g:formatNumber
								number="${auctionInstance.deliveryCosts}" type="currency"
								currencyCode="EUR" /></td>

					</tr>
					
					<tr class="prop">
						<td valign="top" class="name"><g:message
								code="auction.share.label" default="Share" /></td>
						<td valign="top" class="value">
							<!-- Place this tag where you want the +1 button to render -->
							<div class="fb-like"
								data-href="${createLink(controller:'auction', action:'show', id:fieldValue(bean: auctionInstance, field: "id"))}"
								data-send="true" data-layout="button_count" data-width="450"
								data-show-faces="false" data-font="segoe ui"></div>
							<br/> <br/>
							<div class="g-plusone"
								data-href="${createLink(controller:'auction', action:'show', id:fieldValue(bean: auctionInstance, field: "id"))}"></div>
						</td>
					</tr>
				</tbody>
			</table>
			
		</div>
		<g:if test="${session?.admin == true}">
			<div class="buttons">
				<g:form>
					<g:hiddenField name="id" value="${auctionInstance?.id}" />
					<span class="button"><g:actionSubmit class="delete"
							action="delete"
							value="${message(code: 'default.button.delete.label', default: 'Delete')}"
							onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" />
					</span>
				</g:form>
			</div>
		</g:if>
	</div>
</body>
</html>
